public class MySingleList {
    static class ListNode{
        public int val;//节点的值域
        public ListNode next;//下一个节点的地址

        public ListNode(int val) {
            this.val = val;
        }
    }
    public ListNode head;
    public void addLast(int data){
        ListNode node = new ListNode(data);
        ListNode cur = head;
        if(cur == null){
            head = node;
            return;
        }
        while (cur.next != null){
            cur = cur.next;
        }
        cur.next = node;
    }
    public void display(){
        ListNode multiple = head;
        while (multiple != null){
            System.out.print(multiple.val+" ");
            multiple = multiple.next;
        }
        System.out.println();
    }
}
